package cn.wolfcode.rbac.service.impl;

import cn.wolfcode.rbac.domain.Department;
import cn.wolfcode.rbac.mapper.DepartmentMapper;
import cn.wolfcode.rbac.service.IDepartmentService;
import cn.wolfcode.rbac.util.QueryObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by Blank9 on 2020/7/10.
 */
@Service
public class DepartmentServiceImp implements IDepartmentService{
    @Autowired
    private DepartmentMapper departmentMapper;

    @Override
    public void delete(Long id) {
        departmentMapper.deleteByPrimaryKey(id);
    }

    @Override
    public Department get(Long id) {
        return departmentMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<Department> listAll() {

        return departmentMapper.selectAll();

    }

    @Override
    public void saveOrUpdate(Department department) {
        if (department.getId() == null){
            departmentMapper.insert(department);
        }
        if (department.getId() != null){
            departmentMapper.updateByPrimaryKey(department);
        }
    }

    @Override
    public List<Department> query(QueryObject queryObject) {
        return null;
    }
}
